<template>
        <el-card shadow="never" style="max-height: 700px; overflow: auto">
            <el-form ref="form" :model="form" :rules="rules" label-width="90px" :disabled="disabled">
                <el-form-item label="id:" prop="id" v-show="false">
                    <el-input v-model="form.id" disabled />
                </el-form-item>
                <el-form-item label="sku:" prop="sku">
                    <el-input v-model="form.sku" placeholder="请输入sku" clearable />
                </el-form-item>
                <el-form-item label="货架:" prop="shelf">
                    <el-input v-model="form.shelf" placeholder="请输入货架" clearable />
                </el-form-item>
                <el-form-item label="安全:" prop="safe">
                    <el-input v-model="form.safe" placeholder="请输入安全" clearable />
                </el-form-item>
                <el-form-item label="在途:" prop="on">
                    <el-input v-model="form.on" placeholder="请输入在途" clearable />
                </el-form-item>
                <el-form-item label="预售:" prop="pre_sale">
                    <el-input v-model="form.pre_sale" placeholder="请输入预售" clearable />
                </el-form-item>
                <el-form-item label="可用:" prop="usable">
                    <el-input v-model="form.usable" placeholder="请输入可用" clearable />
                </el-form-item>
                <el-form-item label="总量:" prop="sum">
                    <el-input v-model="form.sum" placeholder="请输入总量" clearable />
                </el-form-item>
                <el-form-item label="产品id:" prop="product_id">
                    <el-input v-model="form.product_id" placeholder="请输入产品id" clearable />
                </el-form-item>
                <el-form-item label="skuid:" prop="variants_id">
                    <el-input v-model="form.variants_id" placeholder="请输入skuid" clearable />
                </el-form-item>
                <el-form-item label="编号:" prop="brand">
                    <el-input v-model="form.brand" placeholder="请输入编号" clearable />
                </el-form-item>
                <el-form-item label="备注:" prop="content">
                    <el-input v-model="form.content" placeholder="请输入备注" clearable />
                </el-form-item>
                <el-form-item label="更新时间:" prop="updatetime">
                    <el-date-picker v-model="form.updatetime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择更新时间" />
                </el-form-item>        


                <el-form-item>
                    <el-button type="primary" @click="submitForm">确认 </el-button>
                    <el-button type="warning" @click="cancel">取消 </el-button>
                </el-form-item>
            </el-form>
        </el-card>
</template>

<script>
export default {
    name: 'EditForm',
    props: {
        findFormData: {
            type: Object,
            default: {}
        },
        editFormParams: {
            type: Object,
            default: {}
        },
        // 表单是否禁用
        disabled: {
            type: Boolean,
            default: false,
        },
        
    },
    data() {
        return {
            // 编辑表单验证规则
            rules: {
                sku: [{ required: true, message: "请输入sku", trigger: "blur" }],
                product_id: [{ required: true, message: "请输入产品id", trigger: "blur" }],
                variants_id: [{ required: true, message: "请输入skuid", trigger: "blur" }],
                brand: [{ required: true, message: "请输入编号", trigger: "blur" }],
                updatetime: [{ required: true, message: "请输入更新时间", trigger: "blur" }],
        
            },
            form: {  },
          

        }
    },
    watch: {
        findFormData: {
           handler(nval) {
                if (JSON.stringify(nval) != '{}') {
                    this.$nextTick(() => {
                        this.form = nval
                    })
                }
            },
            immediate: true,
            deep: false,
        },
        
    },
    methods: {
        // 取消按钮
        cancel() {
            this.$emit('editFormCancel')
        },

        submitForm() {
            this.$refs['form'].validate((valid, obj) => {
                if (valid) {
                    this.$emit('submitForm', this.form)
                }
            })
        },

        // 表单重置
        reset() {
            this.resetForm('form')
        }
    }
}
</script>
